package integral;

import enums.IntegralSource;
import enums.IntegralStatus;
import models.BaseModel;
import models.weixin.WebUser;

import javax.persistence.*;
import java.util.List;

/**
 * 积分消费记录
 * Created by youliangcheng on 17/11/18.
 */
@Entity
@Table(name = "integral_get_historys")
public class IntegralGetHistory extends BaseModel {

    /**
     * 关联用户
     */
    @ManyToOne
    @JoinColumn(name = "web_user_id")
    public WebUser webUser;


    /**
     * 添加积分之前账户积分数
     */
    @Column(name = "web_user_integrals")
    public Integer webUserIntegrals;


    /**
     * 增加的积分数量
     */
    @Column(name = "add_integrals")
    public Integer addIntegrals;


    /**
     * 充值金额
     */
    @Column(name = "recharge_amount")
    public Double rechargeAmount;


    /**
     * 充值凭证图片
     */
    @Column(name = "image_path")
    public String imagePath;



    /**
     * 积分来源
     */
    @Column(name = "Integral_source")
    @Enumerated(EnumType.STRING)
    public IntegralSource IntegralSource;

    /**
     * 积分充值状态
     */
    @Column(name = "integral_status")
    @Enumerated(EnumType.STRING)
    public IntegralStatus integralStatus;


    /**
     * 积分来源说明
     */
    @Column(name = "remark")
    public String remark;


    /**
     * 加载用户积分充值记录
     * @param webUser
     * @return
     */
    public static List<IntegralGetHistory> loadByWebUser(WebUser webUser){
        return IntegralGetHistory.find("webUser = ? " , webUser).fetch();
    }













}
